<?php 
	class Class_DatHang extends database
	{
		var $sqlHienThiSanPham = '';
		
		function DanhSachDatHangByMaNguoiBan($MaNguoiBan)
		{
			$this->setQuery('set names utf8');
			$this->Query();
	
			$sql = 'select nm.HinhAnh as HinhAnh, nm.HoTen as HoTen, nm.Username as Username, sp.TenSanPham as TenSanPham, sp.SoLuong as SoLuong, sp.GiaSanPham as GiaSanPham, dh.ThoiGianDatHang as ThoiGianDatHang, dh.TinhTrangPhanHoi as TinhTrangPhanHoi, dh.TrangThaiGiaoDich as TrangThaiGiaoDich, dh.NoiDungDatHang as NoiDungDatHang from dat_hang dh, nguoi_ban nb, san_pham sp, nguoi_mua nm where dh.MaNguoiMua=nm.MaSo and dh.MaSanPham=sp.MaSo and sp.MaNguoiBan=nb.MaSo and nb.MaSo='.$MaNguoiBan;
			//$sql = 'select * from nguoi_ban where MaSo='.$MaNguoiBan;
			
			$this->setQuery($sql);
			$table = $this->LoadAllRow();
			return $table;
		}
		
		function CountDanhSachDatHangByMaNguoiBan($MaNguoiBan)
		{
			$this->setQuery('set names utf8');
			$this->Query();
	
			$sql = 'select * from dat_hang dh, nguoi_ban nb, san_pham sp, nguoi_mua nm where dh.MaNguoiMua=nm.MaSo and dh.MaSanPham=sp.MaSanPham and sp.MaNguoiBan=nb.MaSo and nb.MaSo='.$MaNguoiBan;
	
			$this->setQuery($sql);
			$table = $this->LoadAllRow();
			$num = count($table);
			return $table;
		}
		function HienThiDatHangTheoMaNguoiBan($MaDanhMuc,$start,$limit)
		{
			$this->sqlHienThiDathang = '';
			
			$this->setQuery('set names utf8');
			$this->Query();
			
			$this->sqlHienThiDathang .= 'select * from dat_hang dh, nguoi_ban nb, san_pham sp, nguoi_mua nm where dh.MaNguoiMua=nm.MaSo and dh.MaSanPham=sp.MaSanPham and sp.MaNguoiBan=nb.MaSo and nb.MaSo='.$MaNguoiBan;
			$this->CauTruyVanHienThiSanPham($MaDanhMuc);
			$this->sqlHienThiDathang .= ' order by NgayDang desc limit '.$start.','.$limit ;
	
			$this->setQuery($this->sqlHienThiDathang);
			$table = $this->LoadAllRow();
			return $table;
		}
		

}
?>